From c562e040059667ca7b7fd50fd6bcd44cb880e0a6 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 9 Jan 2006 17:07:30 +0000 Subject: [PATCH] Always duplicate badchar string into handle to eliminate special cases on the handle release. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@1672 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/mkshort.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gpsbabel/mkshort.c b/gpsbabel/mkshort.c index a035062dc..cba30f3e4 100644 --- a/gpsbabel/mkshort.c +++ b/gpsbabel/mkshort.c @@ -85,7 +85,7 @@ mkshort_new_handle() QUEUE_INIT(&h->namelist[i]); h->whitespaceok = 1; - h->badchars = DEFAULT_BADCHARS; + h->badchars = xstrdup(DEFAULT_BADCHARS); h->target_len = DEFAULT_TARGET_LEN; h->must_uniq = 1; h->defname = xstrdup("WPT"); @@ -278,13 +278,9 @@ setshort_badchars(short_handle h, const char *s) { mkshort_handle *hdl = (mkshort_handle *) h; - if ((hdl->badchars != NULL) && (hdl->badchars != DEFAULT_BADCHARS)) + if ((hdl->badchars != NULL)) xfree(hdl->badchars); - if (s == NULL) { - hdl->badchars = DEFAULT_BADCHARS; - } else { - hdl->badchars = xstrdup(s); - } + hdl->badchars = xstrdup (s ? s : DEFAULT_BADCHARS); } /* -- 2.30.2